Want Cursor's AI Agent to intelligently run your custom CLI tools without complex MCP setups or constant hand-holding? If only the AI could understand your tool's --help
output, life would be much simpler. This lesson demonstrates exactly that, leveraging Cursor's "Rules" feature with the "Agent Requested" type. You'll learn to feed your CLI's help text directly into a rule, effectively teaching the AI to operate your custom commands through natural language.
Workflow demonstrated in this lesson:
- Execute your custom CLI tool's
--help
command (e.g.,ghx --help
) and pipe its output to your clipboard (e.g.,| pbcopy
). - Create a "New Cursor Rule" (Cmd/Ctrl + Shift + P, then "New Cursor Rule").
- Paste the copied help text into the main content area of the rule.
- Set the "Rule Type" to "Agent Requested".
- Provide a clear, concise "Description" (e.g., "Search GitHub") that will act as the trigger phrase for the AI.
- In an Agent chat, prompt the AI using natural language that corresponds to your rule's description (e.g., "Search GitHub for examples of package.jsons using semantic-release").
- Observe as the Agent uses the rule's help text to correctly formulate and run your custom CLI command.
- Leverage the tool's output by further instructing the AI to generate or modify project files (e.g., create a
package.json
,.releaserc.json
, orbiome.json
based on findings).
Key benefits:
- Empowers Cursor's AI Agent to directly use your existing custom CLI tools without needing to modify the tools themselves.
- Simple and intuitive setup: Uses your tool's own documentation (
--help
output) as the "API" for the AI. - Efficient context usage: The detailed help text for your tool is only loaded into the AI's context when your specific trigger phrase is detected.
- Provides a straightforward and powerful alternative to MCPs for many CLI tool integration scenarios, especially when tools already have good help messages.
- Enables complex, natural language-driven automation by combining custom tool execution with the AI's code generation and modification capabilities.
By using "Agent Requested" rules, you gain maximum control over how and when the AI interacts with your custom tools, making the Agent a more versatile and powerful assistant tailored to your specific command-line utilities.
Resources